<!DOCTYPE html>
<html lang="en">
<head>
    <link href="ico.ico" rel="SHORTCUT ICON" />
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bill的小游戏平台</title>
</head>
<style>
    *{
        margin: 0;
        padding: 0;
    }
    h1{
        text-align: center;
    }
    .node{
        color: black;
        text-decoration: none;
        text-align: center;
        float: left;
        margin-top: 10px;
        margin-left: 10px;
    }
    .blue{
        background-color: rgba(37, 139, 223, 0.589);
    }
    .black{
        background-color: rgba(0, 0, 0, 0.295);
    }
    .main{
        
        margin: auto;
        border: solid black 1px;
    }
</style>
<body>
    <h1>Bill的小游戏平台</h1>
    <div class="main">

    </div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
<script src="js/coco-message.js"></script>

<script>
    //自适应
    var min;

    var gamelist = [
        {"url": "chess", "name": "步步为营"},
        {"url": "", "name": ""},
        {"url": "", "name": ""},
    ];

    
    window.onresize = flash;
    window.onload = flash;
    function flash(){
        min = window.innerHeight > window.innerWidth ? window.innerWidth : window.innerHeight;
        min = min - 50;

        $(".main").width(min);
        $(".main").height(min);
        w = (min - 40) / 3;        

        arr = $(".node");
        for(i = 0; i < arr.length; i++){
            str = arr.eq(i).html();
            fontlength = str.length;
            fontsize = (w - 30) / fontlength;
            h = (w - fontsize - 10 * fontlength) / 2;
            arr.eq(i).attr("style",
                "padding-top:" + h + "px;" +
                "width:" + w + "px;" +
                "height:" + (w - h) + "px;" +
                "font-size: "+fontsize+"px;"
            );
        }
        
    }
    
    
    var color_key = true;
    for(i in gamelist){
        fontlength = gamelist[i].name.length;
        node = $("<a>");
        
        node.addClass("node");
        node.addClass(color_key ? "blue" : "black");
        
        node.attr("href",
            gamelist[i].url
        );
        color_key = !color_key;
        node.html(gamelist[i].name);
        $(".main").append(node);
    }
    flash();

</script>
</html>